package com.xjtu.mybatisplus.common.utls;

import com.xjtu.mybatisplus.common.constant.RedisConstant;
import com.xjtu.mybatisplus.model.domain.Comment;
import com.xjtu.mybatisplus.model.domain.Mailbox;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class Producer {
    @Autowired
    private RedisUtil redisUtil;
    /**
     * 评论使用这个消息队列来实现
     *
     * @param comment
     */
    public void produceMessage(Comment comment) {
        // 存入redis中
        redisUtil.lpush(RedisConstant.COMMENT_QUEUE, comment);
    }

    /**
     * 信箱使用这个消息队列来实现
     * @param mailbox
     */
    public void produceMessage(Mailbox mailbox) {

    }


//    public Mailbox cosumeMaliboxMessage() {
//        Mailbox mailbox = (Mailbox) redisUtil.brpop(RedisConstant.MAILBOX_QUEUE);
//        return mailbox;
//    }
}
